package ink.lvxin.hadoop.service;

import java.util.ArrayList;
import java.util.List;

public class Hadoop {
    public static void main(String[] args){
        String[] r = getBallGroups(4);
        for(String s : r){
            System.out.println(s);
        }
    }

    public static String[] getBallGroups(int num){
        if (num <= 0){
            return new String[]{};
        }

        if (num == 1){
            return new String[]{"1"};
        }

        String[] pre = getBallGroups(num - 1);
        List<String> list = new ArrayList<>();
        for(String s : pre){
            list.add(s);
        }

        for(String s : pre){
            list.add(s + "," + num);
        }

        list.add(String.valueOf(num));

        String[] r = new String[list.size()];

        return list.toArray(r);
    }

}
